﻿Public Class FormOper0
    Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    Public usr As String
    Public source As String
    Public ty As String
    Public b_gt_sys_id As String
    Public pw_ok_num_all As String
    Public oper_num_all As String
    Dim objGtProcedureDetails As New clsGtProcedureDetails
    Private Sub FormOper0_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lblgt.Text = b_gt_sys_id
        setData()
    End Sub

    Private Sub setData()
        SpinEdit1.Value = Decimal.Parse(pw_ok_num_all)
        SpinEdit2.Value = Decimal.Parse(oper_num_all)
        txt_operable_num.Value = SpinEdit1.Value - SpinEdit2.Value
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If Integer.Parse(txt_num.Value) > 0 Then
            If Integer.Parse(txt_num.Value) <= Integer.Parse(txt_operable_num.Value) Then
                Dim en As New entity_gt_procedure_details
                If Me.source.Equals("jp") Then
                    en.procedure_No = "0"
                Else
                    en.procedure_No = "1"
                End If
                en.oper_num = Integer.Parse(txt_num.Value)
                en.b_gt_sys_id = Integer.Parse(lblgt.Text)
                en.validity = "1"
                en.oper = usr
                Dim rtn As Integer = objGtProcedureDetails.save(en)
                If rtn <> -2 Then
                    MsgBox("入料成功")
                    If source.Equals("check") Then
                        CType(Owner, FormCheck).SetDgvResultData1()
                        CType(Owner, FormCheck).setDgvNgOperData()
                    Else
                        If ty.Equals("0") Then
                            CType(Owner, FormOperJP).setDgvOperData()
                            CType(Owner, FormOperJP).SetDgvResultData1()
                        ElseIf ty.Equals("00") Then
                            CType(Owner, FormOperPSQX00).setDgvOperData()
                            CType(Owner, FormOperPSQX00).SetDgvResultData1()
                        Else
                            CType(Owner, FormOperPSQX1).setDgvOperData()
                            CType(Owner, FormOperPSQX1).SetDgvResultData1()
                        End If
                    End If
                    Close()
                Else
                    MsgBox("入料失败")
                End If
            Else
                MsgBox("入料数量需<=可入料总数量")
            End If
        Else
            MsgBox("入料数量需>0")
        End If
    End Sub


    Private Sub txt_num_MouseDown(sender As Object, e As MouseEventArgs) Handles txt_num.MouseDown
        UcDigitalKeyboard1 = New ucDigitalKeyboard
        If sender.MaskBox.Mask.EditMask = "d" Then
            UcDigitalKeyboard1.B_01 = False
        Else
            UcDigitalKeyboard1.B_01 = True
        End If

        If sender.GetType().Name.Equals("TextEdit") Then
            UcDigitalKeyboard1.B_02 = True
        Else
            UcDigitalKeyboard1.B_02 = False
        End If

        UcDigitalKeyboard1.Txt = sender

        Me.Controls.Add(UcDigitalKeyboard1)
        UcDigitalKeyboard1.Show()
        UcDigitalKeyboard1.BringToFront()
        UcDigitalKeyboard1.Focus()
    End Sub


End Class